"""chemtimes URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path ,include, re_path
from apps.index import views
from apps.Userinfo import views as U
from django.views.static import serve
#导入静态文件模块
from django.conf import settings
#导入配置文件里的文件上传配置

from django.conf.urls.static import static


urlpatterns = [
    path('admin/', admin.site.urls),
    path('', views.index.get, name='index'),
    path('ueditor/', include('DjangoUeditor.urls')),
    re_path('^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),#增加此行
    re_path('^search/media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),#增加此行
    re_path('^article/*/media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),#增加此行

    path('article_list/', views.article.article_list, name='article_list'),
    path('search/', views.index.search, name='search'),
    path('article/<int:id>', views.article.article_details, name='article_details'),

    path('uc-account/', U.UC.account, name='uc_account'),
    path('uc-verify/', U.UC.uc_verify, name='uc_verify'),
    path('uc-verify2/', U.UC.uc_verify2, name='uc_verify2'),
    path('uc-verify3/', U.UC.uc_verify3, name='uc_verify3'),
    path('change-pwd/', U.UC.change_pwd, name='change_pwd'),
    path('uc-collection/', U.UC.uc_collection, name='uc_collection'),
    path('uc-collect/<str:flag>/<int:id>', U.UC.uc_collect, name='uc_collect'),
    path('uc-contact', U.UC.uc_contact, name='uc_contact'),
    path('uc-contact-free', U.UC.uc_contact_free, name='uc_contact_free'),
    path('uc-vip', U.UC.uc_vip, name='uc_vip'),

    path('uc-history/', U.UC.uc_history, name='uc_history'),
    path('login/', U.Login.login, name='login'),
    path('logout/', U.Login.logout, name='logout'),


    path('register/', U.RegisterView.as_view(), name='register'),
    path('forgot_pwd/', U.RegisterView.forgot_pwd, name='forgot_pwd'),
    path('send_pwd_mail/', U.RegisterView.send_pwd_mail, name='send_pwd_mail'),
    path('sendsnscode', U.RegisterView.sendsnscode, name='sendsnscode'),
    path('checksnscode', U.RegisterView.checksnscode, name='checksnscode'),
    path('change_pwd', U.RegisterView.link_change_pwd, name='link_change_pwd'),
    path('active_user', U.RegisterView.active_user, name='active_user'),
    path('re_active_email_send/<str:email>', U.RegisterView.re_active_email_send, name='re_active_email_send'),

    path('test_email', U.RegisterView.test_email, name='test_email'),
    path('getCategory/', views.index.getCategory, name='getCategory'),
    path('getCategory2/', views.index.getCategory2, name='getCategory2'),

    path('page/<str:link>', views.index.page, name='page'),
]

if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)